<template>
	<view>
		<view class="sousuo">
			<u-search v-model="sousuoVal" @search="sousuoFun" placeholder="请输商品名称" height="48" margin="16rpx 0" :action-style="sousouBtn"
			 bg-color="#fff" @custom='sousuoFun'></u-search>
		</view>
		<view class="shopBox">
			<u-row>
				<u-col span="6" v-for="(item,index) in shoparr" :key='index'>
					<view class="shopval" @click="gopage(item)">
						<u-image width="100%" height="344rpx" :src="item.image" mode="aspectFit"></u-image>
						<view class="shop_name">
							{{item.store_name}}
						</view>
						<view class="shop_msg">
							{{item.store_info ? item.store_info :''}}
						</view>
						<view class="jiageBox">
							FCFA{{item.price}}
						</view>
					</view>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sousuoVal: "",
				sousouBtn: {
					width: "100rpx",
					background: "#808080",
					borderRadius: '24rpx',
					color: "#fff",
					fontSize: "26rpx",
					height: "48rpx",
					lineHeight: "48rpx"
				},
				shoparr: [],
			};
		},
		onLoad() {
			uni.getStorage({
				key: 'userinfo',
				success: (res) => {
					this.info = res.data
				}
			})
			this.getshangpin()
		},
		methods: {
			getshangpin() {
				uni.request({
					url: this.$AJAX_URL + 'goods/product_good_list',
					success: (res) => {
						if (res.data.code === 200) {
							this.shoparr = res.data.data
						}
					}
				})
			},
			sousuoFun(value) {
				uni.request({
					url: this.$AJAX_URL + 'goods/product_list',
					method: 'POST',
					data: {
						keyword: value
					},
					success: (res) => {
						// console.log(res);
						this.shoparr = res.data.data.list
					}
				})
			},
			gopage(item) {
				uni.navigateTo({
					url: '../xiangqing/xiangqing?id=' + item.id
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
	}

	.sousuo {
		padding: 0 30rpx;
		// background: #FFFFFF;
	}

	.shopBox {
		margin-top: 40rpx;
		background: #f7f7f7;

		.shopval {
			margin-bottom: 20rpx;
			height: 540rpx;
			border-radius: 20rpx;
			background: #FFFFFF;
			overflow: hidden;

			.shop_name {
				margin-left: 15rpx;
				font-size: 32rpx;
				margin-top: 19rpx;
				margin-right: 20rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.shop_msg {
				margin-left: 10rpx;
				margin-right: 28rpx;
				font-size: 24rpx;
				color: #333333;
				margin-top: 10rpx;
			}

			.jiageBox {
				color: #FF392B;
				font-size: 30rpx;
				margin-left: 17rpx;
				margin-top: 10rpx;
			}
		}
	}
</style>
